package cn.adolf.carmaster.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import cn.adolf.carmaster.R;

public class MenuActivity extends AppCompatActivity {

    public static final String EXTRA_TYPE = "menu_type";
    public static final String MENU_ABOUT = "关于";
    public static final String MENU_HELP = "帮助";
    private String title = MENU_ABOUT;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);
        if (getIntent() != null) {
            title = getIntent().getStringExtra(EXTRA_TYPE);
        }
        setTitle(title);

        switch (title) {
            case MENU_HELP:
                HelpFragment helpFragment = new HelpFragment();
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.fragment, helpFragment, "help")
                        // .addToBackStack("help")
                        .commitAllowingStateLoss();
                break;
            case MENU_ABOUT:
                AboutFragment aboutFragment = new AboutFragment();
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.fragment, aboutFragment, "about")
                        // .addToBackStack("about")
                        .commitAllowingStateLoss();
                break;
        }
    }
}